package com.example.day18;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;

/**
 * @author Lenovo
 */
public class FileToArrayListDemo {
    public static void main(String[] args) throws IOException, java.io.IOException {
        BufferedReader br = new BufferedReader(new FileReader("myCharStream\\students.txt"));
        ArrayList<Student> array = new ArrayList<Student>();
        String line;
        while ((line = br.readLine()) != null) {
            String[] strArray = line.split(",");
            Student s = new Student();
            s.setSid(strArray[0]);
            s.setName(strArray[1]);
            s.setAge(Integer.parseInt(strArray[2]));
            s.setAddress(strArray[3]);
            array.add(s);
        }
        br.close();
        for (Student s : array) {
            System.out.println(s.getSid() + "," + s.getName() + "," +
                    s.getAge() + "," + s.getAddress());

        }
    }
}